Is there a "more direct" way to list only the unique link modules associated with a formal module? |
Re: List only the unique Link Modules associated a Formal Module The standard DXL tool for this sort of things are Skip lists. If you create a skip list and use the link module name as string key and value, then the Skip list will only contain the unique values. Simple example:
Skip sList = createString
string s
s = "Hey"
put(sList, s, s)
put(sList, s, s)
s = "Ho"
put(sList, s, s)
put(sList, s, s)
s = "Let's"
put(sList, s, s)
put(sList, s, s)
s = "go"
put(sList, s, s)
put(sList, s, s)
for s in sList do {print s " "}
You see, although I am adding each string twice, each second try is ignored and the SKip list only holds the unique values. |
Re: List only the unique Link Modules associated a Formal Module For the first, you go to every object and plow through every outgoing "Link" or incoming "LinkRef", get the name, and as Albert suggest put it in a Skip list; which just ignores duplicates. For the 2nd, you need to get the folder of the module, plow through all the LinkModuleDescriptors in the folder, ignore the Sources taht don't match your module, then get the LinkModule and likewise dump it into a Skip. Then as Albert says print the contents of the Skip.
|
Re: List only the unique Link Modules associated a Formal Module For what it's worth, here's the very brief dxl I put together on the back of this in case anyone else finds it helpful (no doubt could be optimised but does what I need today): // Show the unique Link Modules associated with each Formal Module within a Folder/Project /* Lists the unique Link Modules used by link direction. */ pragma runLim, 0 // Prevent DXL timeout Item Mods for Mods in current Folder do // Interchange "Project" & "Folder" to define scope { if (type Mods == "Formal") // Ignore Link and Descriptive Modules { // Define Skip List related variables Skip sInList = createString Skip sOutList = createString string s // Define Module related variables Module m = read(fullName(Mods), false) // Open the Module read-only Object o Link l // Use Link data for Out-links LinkRef lr // Use LinkRef data for In-Links // Process Outbound Links print name m " Outbound Link Module Names:" "\n" // For correct ordering of Text in DXL Output, identify Module name being processed before entering loop for o in m do { for l in o -> "*" do { put(sOutList, name module l, name module l) // Populate Skip List using Link Module name as key to ignore duplicates and keep to only unqiue values } } for s in sOutList do {print s "\n"} // Print contents of Skip List to DXL Output (under corresponding Module Name and Link Direction text printed previously) // Process Inbound Links print name m " Inbound Link Module Names:" "\n" // For correct ordering of Text in DXL Output, identify Module name being processed before entering loop for o in m do { for lr in o <- "*" do { put(sInList, name module lr, name module lr) // Populate Skip List using Link Module name as key to ignore duplicates and keep to only unqiue values } } for s in sInList do {print s "\n"} // Print contents of Skip List to DXL Output (under corresponding Module Name and Link Direction text printed previously) print "\n" // Print a blank line between Modules for ease of reading // Tidy up close m delete(Skip sOutList) delete(Skip sInList) } } infoBox "Actions Complete - Details printed in DXL Output pane." |
Re: List only the unique Link Modules associated a Formal Module gmtg - Fri Feb 11 06:38:13 EST 2011 Just because I like to show off, you could count the links as well.
//*********************
bool fPutSkipIncrement(Skip skpList, string KeyValue)
{ // Insert the KeyValue into the Skip list's 'Key'.
// The 'Data' portion of the Skip is set to 1 for new inserts and is
// incremented for already existing 'Key's in the Skip.
// 'Data' MUST be of type Integer.
// (represents the number of references).
// Return whether this is a first insert for KeyValue into the Skip.
bool IsNewValue = false
int NumReferences = 0 // Remains zero if next "find" doesn't find anything:
if(find(skpList, KeyValue, NumReferences))
delete(skpList, KeyValue) // Remove It
else IsNewValue = true // Mark it New
// ReInsert new or updated counts
NumReferences++
put (skpList, KeyValue, NumReferences)
return(IsNewValue)
} // end fPutSkipIncrement()
|